package com.yvan.periscope.domain;

import com.yvan.metric.Consts;
import com.yvan.platform.StringUtils;

/**
 * Created by Blues Zhao on 上午11:26 2018/8/17.
 */
public enum  HistogramTitleEnum {
    //sql-耗时
    SQL_JDBC_STMT_TIME("sql", "cost", "时间区间(ms)", "请求次数", Consts.JDBC_STMT_TIME),
    //sql-等待
    SQL_JDBC_CONNECT_ALIVED("sql", "hold", "时间区间(ms)", "请求次数", Consts.JDBC_CONNECT_ALIVED),
    //sql-查询行数
    SQL_JDBC_FETCH_ROW("sql", "select", "数据行数", "请求次数", Consts.JDBC_FETCH_ROW),
    //sql-更新行数
    SQL_JDBC_UPDATE_COUNT("sql", "update", "数据行数", "请求次数", Consts.JDBC_UPDATE_COUNT),
    //url-耗时
    URL_HTTP_COST_HISTOGRAM("url", "cost", "时间区间(ms)", "请求数", Consts.HTTP_COST_HISTOGRAM),
    //jdbc连接挂起
    SUMMARY_TXH_HISTOGRAM("summary", "txh", "时间区间(ms)", "请求数", Consts.TXH_HISTOGRAM),
    //jdbc事务执行时间
    SUMMARY_TXN_HISTOGRAM("summary", "txn", "时间区间(ms)", "请求数", Consts.TXN_HISTOGRAM),
    //redis耗时
    SUMMARY_RDS_COST_HISTOGRAM("summary", "rds_c", "时间区间(ms)", "请求数", Consts.RDS_COST_HISTOGRAM),
    //redis结果大小
    SUMMARY_RDS_RES_HISTOGRAM("summary", "rds_s", "结果大小区间(字节)", "请求数", Consts.RDS_RES_HISTOGRAM),
    //es查询耗时
    SUMMARY_ES_COST_HISTOGRAM("summary", "es_c", "时间区间(ms)", "请求数", Consts.ES_COST_HISTOGRAM),
    //es请求大小
    SUMMARY_ES_REQ_HISTOGRAM("summary", "es_r", "请求大小区间(字节)", "请求数", Consts.ES_REQ_HISTOGRAM),
    //es结果大小
    SUMMARY_ES_RES_HISTOGRAM("summary", "es_s", "结果大小区间(字节)", "请求数", Consts.ES_RES_HISTOGRAM),
    //url-耗时
    SUMMARY_HTTP_COST_HISTOGRAM("summary", "cost", "时间区间(ms)", "请求数", Consts.HTTP_COST_HISTOGRAM);




    // 成员变量
    private String index;
    private String histogramPrefix;
    private String xAxisTitle;
    private String yAxisTitle;
    private long [] Partition;
    // 构造方法
    private HistogramTitleEnum(String index, String histogramPrefix,String xAxisTitle,String yAxisTitle,long [] Partition) {
        this.index = index;
        this.histogramPrefix = histogramPrefix;
        this.xAxisTitle = xAxisTitle;
        this.yAxisTitle = yAxisTitle;
        this.Partition = Partition;
    }
//    // 普通方法
    public static HistogramTitleEnum getEnum(String index, String histogramPrefix) {
        if(StringUtils.isNullOrEmpty(index) || StringUtils.isNullOrEmpty(histogramPrefix)){
            return null;
        }
        for (HistogramTitleEnum c : HistogramTitleEnum.values()) {
            if (index.equals(c.index) && histogramPrefix.equals(c.histogramPrefix)) {
                return c;
            }
        }
        return null;
    }


    public String getIndexPattern() {
        return index;
    }

    public void setIndexPattern(String index) {
        this.index = index;
    }

    public String getHistogramPrefix() {
        return histogramPrefix;
    }

    public void setHistogramPrefix(String histogramPrefix) {
        this.histogramPrefix = histogramPrefix;
    }

    public String getxAxisTitle() {
        return xAxisTitle;
    }

    public void setxAxisTitle(String xAxisTitle) {
        this.xAxisTitle = xAxisTitle;
    }

    public String getyAxisTitle() {
        return yAxisTitle;
    }

    public void setyAxisTitle(String yAxisTitle) {
        this.yAxisTitle = yAxisTitle;
    }

    public long[] getPartition() {
        return Partition;
    }

    public void setPartition(long[] partition) {
        Partition = partition;
    }
}
